package com.ihk.toiletfinder;

import com.ihk.model.UserLocation;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity implements OnClickListener {

	Button currentLocationButton;
	Button specificLocationButton;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        currentLocationButton = (Button) findViewById(R.id.currentLocationButton);
        currentLocationButton.setOnClickListener(this);
        
        specificLocationButton = (Button) findViewById(R.id.specificLocationButton);
        specificLocationButton.setOnClickListener(this);
    }
    
    public void onClick(View v){
    	if(v == currentLocationButton){
    		UserLocation.getInstance().setGpsEnable(true);
    		Intent i = new Intent(this, OpenStreetMapActivity.class);
    		startActivity(i);
    	}
    	else if(v == specificLocationButton){
    		UserLocation.getInstance().setGpsEnable(false);
    		Intent i = new Intent(this, SearchActivity.class);
    		startActivity(i);
    	}
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu, menu);
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	switch (item.getItemId()) {
    	case R.id.itemSettings:
    		startActivity(new Intent(this, SettingsActivity.class));
    		break;
    	case R.id.itemAddToilet:
    		startActivity(new Intent(this, AddToiletActivity.class));
    	break;
    	}
    	
    	return true;
    }

    
}
